import time

from company_wechat.base import Base
from selenium.webdriver.common.by import By

from company_wechat.login import Login
from company_wechat.register import Register


class Main(Base):
    _base_url = 'http://demo.pan.rubinchu.com/'
    def goto_login(self):
        self.find(By.CSS_SELECTOR,'.el-button submit el-button--warning is-round').click()
        return Login(self._driver)

    def goto_register(self):
        time.sleep(3)
        #此段的主要原因是这个元素不可点击，所以用js的方法执行
        js = self.find(By.XPATH,'//*[@class="m--up"]')
        self._driver.execute_script("arguments[0].click();",js)
        return Register(self._driver)
